//点击弹出退出登录确认窗口
$("#sign_out").click(function(){  
   $(".signout_window").show();
});
//点击取消退出登录
$(".btn_cancel").click(function(){  
   $(".signout_window").hide();
});

//日期格式化：年、月、日
Date.prototype.format = function(format) //author: meizz
{
    var o = {
        "M+" : this.getMonth()+1, //month
        "d+" : this.getDate(),    //day
        "h+" : this.getHours(),   //hour
        "m+" : this.getMinutes(), //minute
        "s+" : this.getSeconds(), //second
        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
        "S" : this.getMilliseconds() //millisecond
    }
    if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
        (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)if(new RegExp("("+ k +")").test(format))
        format = format.replace(RegExp.$1,
            RegExp.$1.length==1 ? o[k] :
                ("00"+ o[k]).substr((""+ o[k]).length));
    return format;
}

function dateValid() {
    var beginDate = new Date(document.getElementById("date1").value.replace(/-/g, "/"));
    var endDate = new Date(document.getElementById("date2").value.replace(/-/g, "/"));
    if (beginDate > endDate) {
        return false;
    }
    return true;
}

function getTime(date)
{
    var myDate= date; //得到时间对象
    var y=myDate.getFullYear(); //获取年
    var m=myDate.getMonth()+1; //获取月
    m=m>9?m:"0"+m; //如果月份小于10,则在前面加0补充为两位数字
    var d=myDate.getDate(); //获取日
    d=d>9?d:"0"+d; //如果天数小于10,则在前面加0补充为两位数字
    var h=myDate.getHours(); //获取小时
    h=h>9?h:"0"+h; //如果小时数字小于10,则在前面加0补充为两位数字
    var M=myDate.getMinutes(); //获取分
    M=M>9?M:"0"+M; //如果分钟小于10,则在前面加0补充为两位数字
    var s=myDate.getSeconds(); //获取秒
    s=s>9?s:"0"+s; //如果秒数小于10,则在前面加0补充为两位数字
    var nowtime=y+"-"+m+"-"+d+" "+h+":"+M+":"+s; //串联字符串用于输入
    return nowtime;
}

function hasClass(obj, cls) {
    return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}

function addClassJS(obj, cls) {
    if (!this.hasClass(obj, cls)) obj.className += " " + cls;
}

function removeClassJS(obj, cls) {
    if (hasClass(obj, cls)) {
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
        obj.className = obj.className.replace(reg, ' ');
    }
}


function addMonth(date, num) {
    num = parseInt(num);
    var sDate = dateToDate(date);

    var sYear = sDate.getFullYear();
    var sMonth = sDate.getMonth() + 1;
    var sDay = sDate.getDate();

    var eYear = sYear;
    var eMonth = sMonth + num;
    var eDay = sDay;
    while (eMonth > 12) {
        eYear++;
        eMonth -= 12;
    }
    while (eMonth <= 0){
        eYear--;
        eMonth = 12 + eMonth;
    }
    var eDate = new Date(eYear, eMonth - 1, eDay);


    while (eDate.getMonth() != eMonth - 1) {
        eDay--;
        eDate = new Date(eYear, eMonth - 1, eDay);
    }
    return eDate;
}

function dateToDate(date) {
    var sDate = new Date();
    if (typeof date === 'object'
        && typeof new Date().getMonth === "function"
    ) {
        sDate = date;
    }
    else if (typeof date === "string") {
        var arr = date.split('-');
        if (arr.length === 3) {
            sDate = new Date(arr[0] + '-' + arr[1] + '-' + arr[2]);
        }
    }
    return sDate;
}




















